@extends('admin.app')

@section('content')
  <div class="panel panel-default">
    <div class="panel-heading font-bold">
      发标记录
    </div>
    <div class="panel-body">
      <form action="{{ admin_action('Business\DemandController@index') }}" class="form-horizontal">
        <div class="form-group">
          <div class="col-sm-1 control-label">借款人</div>
          <div class="col-sm-2">
            <input type="text" class="form-control" name="name" value="{{ $query['name'] ?? '' }}" placeholder="请输入借款人">
          </div>
          <div class="col-sm-1 control-label">标题</div>
          <div class="col-sm-2">
            <input type="text" class="form-control" name="search" value="{{ $query['search'] ?? '' }}" placeholder="请输入标题">
          </div>
          <div class="col-sm-1 control-label">状态</div>
          <div class="col-sm-2">
            <select name="status" class="form-control">
              <option value="">全部</option>
              @foreach($status as $item)
              <option value="{{$item->code}}" {{ isset($query['status'])&&$item->code==$query['status']?'selected':''}}>{{$item->name}}</option>
              @endforeach
            </select>
          </div>
          <div class="pull-right m-r">
            <button class="btn btn-primary" type="submit">查询</button>
            <a class="btn btn-default btn-addon" href="{{ admin_action('Business\DemandController@cate') }}">
              <i class="fa fa-plus"></i>发标
            </a>
          </div>
        </div>
      </form>
      <div class="table-responsive">
        <table class="table table-striped b-t b-light">
          <thead>
            <tr>
              <th>借款人</th>
              <th>流水号</th>
              <th>融资标题</th>
              <th>创建时间</th>
              <th>成立时间</th>
              <th>应还款时间</th>
              <th>融资金额(元)</th>
              <th>项目类型</th>
              <th>状态</th>
              <th>操作</th>
            </tr>
          </thead>
          <tbody>
            @forelse ($list as $row)
            <tr>
              <td>{{$row->financier_name}}</td>
              <td>{{$row->sn}}</td>
            	<td>{{$row->projects_name}}</td>
              <td>{{$row->created_at}}</td>
              <td>{{$row->interest_at}}</td>
              <td>{{$row->trade_repayment_date}}</td>
            	<td>{{$row->finance_money}}</td>
            	<td>{{$row->type()->name}}</td>
              <td>{{$row->status()->name??''}}</td>
            	<td>
            		<a class="btn btn-xs btn-info" href="{{ admin_action('Business\DemandController@show', [$row]) }}" data-toggle="tooltip" title="查看该项目详情">
                  <i class="fa fa-info"></i>
                </a>
                <!-- 修改项目合同 -->
                @if($row->status == 'payment' || $row->status == 'finish')
                <a class="btn btn-xs btn-danger" href="{{ admin_action('Business\DemandController@editProjectFile', [$row]) }}" data-toggle="tooltip" title="修改项目合同">
                  <i class="fa fa-edit"></i>
                </a>
                @endif
                <!-- 修改、删除 -->
                @if($row->status=='none' || $row->status=='stop' || $row->status=='down' || $row->status=='check')
                <a class="btn btn-xs btn-primary" href="{{ admin_action('Business\DemandController@edit', [$row]) }}" data-toggle="tooltip" title="修改项目">
                  <i class="fa fa-pencil"></i>
                </a>
                <form class="inline" action="{{ admin_action('Business\DemandController@destroy', [$row]) }}" method="post">
                  {{ csrf_field() }}
                  {{ method_field('DELETE') }}
                  <button type="button" data-swal-role="delete-confirm" data-swal-title="温馨提示" data-swal-text="删除后不可恢复,是否确定？" class="btn btn-xs btn-danger" data-toggle="tooltip" title="删除项目">
                      <i class="fa fa-trash-o"></i>
                  </button>
                </form>
                @endif
                <a class="btn btn-xs btn-success" href="{{ admin_action('Business\DemandController@copy', [$row]) }}" data-toggle="tooltip" title="复制项目">
                  <i class="fa fa-copy"></i>
                </a>
                <!-- 下线 -->
                @if($row['status']!='down' && $row['financed_money']==0)
                <a href="{{ admin_action('Business\DemandController@down',[$row]) }}" class="btn btn-xs btn-warning" onclick="return confirm('下线后不可恢复,是否确定？')">强制下线</a>
                @endif
                <!-- 分润、投资 -->
                @if($row->status!='stop' || $row->status!='none')
                <a href="{{admin_action('Business\DemandController@profit',[$row])}}" class="btn btn-xs btn-default">分润详情</a>
                <a href="{{admin_action('Business\DemandController@investment',[$row])}}" class="btn btn-xs btn-default">投资详情</a>
                @endif
                <a href="{{admin_action('Business\DemandController@trades',[$row])}}" class="btn btn-xs btn-default">交易记录</a>
              </td>
            </tr>
            @empty
            <tr>
              <td colspan="5" class="text-center">没有找到记录</td>
            </tr>
            @endforelse
          </tbody>
        </table>
      </div>
    </div>
    <div class="panel-footer">
      <div class="row">
        <div class="col-sm-12 text-right text-center-xs">                
          {{ $links }}
        </div>
      </div>
    </div>
  </div>
@endsection